/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.blog.city.checkthedep.sessionbeans;

import com.blog.city.checkthedep.entities.Comment;
import com.blog.city.checkthedep.entities.RegisteredUser;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Breath
 */
@Stateless
public class CommentFacade extends AbstractFacade<Comment> implements CommentFacadeLocal {
    @PersistenceContext(unitName = "com.blog.city_CheckTheDep_war_1.0-SNAPSHOTPU")
    private EntityManager em;

    /**
     * 
     * @return
     */
    protected EntityManager getEntityManager() {
        return em;
    }

    /**
     * 
     */
    public CommentFacade() {
        super(Comment.class);
    }
    
    
    @Override
    public List<Comment> findByRegUserId(RegisteredUser regId) {
        return (List<Comment>) this.getEntityManager().createQuery("SELECT c FROM Comment c WHERE c.registeredUserId= :registeredUserId").setParameter("registeredUserId", regId).getResultList();
    }
}
